package edu.zut.cs.software.cms.module.score.service.impl;

import java.util.Optional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import edu.zut.cs.software.cms.base.service.impl.GenericManagerImpl;
import edu.zut.cs.software.cms.module.score.dao.ScoreDao;
import edu.zut.cs.software.cms.module.score.domain.Score;
import edu.zut.cs.software.cms.module.score.service.ScoreManager;
/**
 * 
 * @author admix
 *
 */


@Service//(value="scoreManager")
//@Transactional
public class ScoreManagerImpl extends GenericManagerImpl<Score, Long> implements ScoreManager {

	ScoreDao scoreDao;

	
	@Autowired
	public void setScoreDao(ScoreDao scoreDao) {
		this.scoreDao = scoreDao;
		this.dao=this.scoreDao;
	}


/*	@Override
	public boolean deleteById(long id) {
		// TODO Auto-generated method stub
		if(scoreDao.ifOneExist(id)>0)
			return true;
		else
			return false;
	}
*/
	@Override
	public Boolean deleteById(Long id) {
		Optional<Score> score=this.dao.findById(id);
		if(score.equals(Optional.empty())) {
			return false;
		}else {
			this.dao.delete(score.get());
			return true;
		}
		
	}
	@Override
	public boolean modifyById(long id,String usual_score,String final_score,String total_score) {
		// TODO Auto-generated method stub
		Score score=new Score();
		score=scoreDao.modifyById(id);
		score.setTotal_score(total_score);
		score.setFinal_score(final_score);
		score.setUsual_score(usual_score);
		return true;
	}


	@Override
	public boolean IfExist(String id) {
		// TODO Auto-generated method stub
		return true;
	}

}
